package com.lingCheng.avg.controller;



import com.lingCheng.avg.common.*;
import com.lingCheng.avg.service.*;
import org.hibernate.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/api")
public class CountController {
    @Autowired
    private WmsTaskHisService wmsTaskHisService;
    @Autowired
    private LocateService locateService;
    @Autowired
    private WcsTrkHisService wcsTrkHisService;
    @Autowired
    private WcsTrkService wcsTrkService;
    @Autowired
    private MemItemService memItemService;

    @Autowired
    private DingShiRW ds;

    /*
    *  当日任务统计
    * */
    @GetMapping("/todayTask")
    public Response todayTask(){
        TaskStatisticsData data = wmsTaskHisService.findTodayAllRW();
        return new Response(200,"success",data);
    }
    /*
     *  当月任务统计
     * */
    @GetMapping("/sevenDayTask")
    public Response servenDayTask(){
        TaskStatisticsData data= wmsTaskHisService.findSevenDayAllRW();
        return new Response(200,"success",data);
    }
    /*
    * 货位使用情况
    * */
    @GetMapping("/storageStatic")
    public Response storageStatic(){
        TaskData data = locateService.findStorageStatic();
        return new Response(200,"success",data);
    }


    /*
    *设备稼动率
    * */

    @GetMapping("/deviceActionRate")
    public Response deviceActionRate(){
        JiaDongData allRW = wcsTrkHisService.findAllRW();
        return new Response(200,"success",allRW);
    }

    /*
    *设备故障率
    * */
    @GetMapping("/deviceErrorRate")
    public Response deviceErrorRate(){
        List<SheBeiData> data = wcsTrkService.findDeviceError();
        return new Response(200,"success",data);
    }

    /*
    *区域运行状态 // 轮询展示当前故障信息
    * */
    @GetMapping("/errorInfo")
    public Response errorInfo(){
        List<ErrorData> data = memItemService.findErrorInfo();
        return new Response(200,"success",data);
    }

    /*
    * 库位状态
    * */
    @GetMapping("/storageMap")
    public Response storageMap(){
        List<StorageData> data = locateService.findStorageStatus();
        return new Response(200,"success",data);
    }

    @GetMapping("/getStackerInfo")
    public Response getStackerInfo(@RequestParam String deviceId){
        deviceId = "SRM_0"+deviceId;
        List<Map<String,Object>> listMap = memItemService.getSrmInfo(deviceId);
        return new Response(200,"success",listMap);
    }

    @GetMapping("test")
    public Response test(){
        ds.GET_AGV_INFO();
        return new Response(200,"",null);
    }

//    /*
//    * 库位状态
//    * */
//    @GetMapping("/storageMap2")
//    public Response storageMap2(@RequestParam int currentPage, @RequestParam int pageSize){
//        List<StorageData> data = locateService.findStorageStatus2(currentPage,pageSize);
//        return new Response(200,"success",data);
//    }
}
